/* 是否手机号码*/
export function validatePhone(rule, value, callback) {

    const reg = /^[1][3,4,5,7,8][0-9]{9}$/;
    if (value == '' || value == undefined || value == null) {
        callback();
    } else {
        if ((!reg.test(value)) && value != '') {
            callback(new Error('请输入正确的电话号码'));
        } else {
            callback();
        }
    }
}

/* 薪水格式是否正确*/
export function validateSalary(rule, value, callback) {
    const reg = /([1-9]([0-9]+)?(.[0-9]{1,2})?$)|(^(0){1}$)|([0-9].0-9?$)/;
    if (value == '' || value == undefined || value == null) {
        callback();
    } else {
        if ((!reg.test(value)) && value != '') {
            callback(new Error('薪水格式错误'));
        } else {
            callback();
        }
    }
}

/* 项目周期格式是否正确*/
export function validateWorkCycle(rule, value, callback) {
    const reg = /^\+?[1-9][0-9]*$/;
    if (value == '' || value == undefined || value == null) {
        callback();
    } else {
        if ((!reg.test(value)) && value != '') {
            callback(new Error('项目周期格式错误'));
        } else {
            callback();
        }
    }
}

/* 项目技能是否正确*/
export function validateSkills(rule, value, callback) {
    if (value == '' || value == undefined || value == null) {
        callback(new Error('请选择技能'));
    } else {
        callback();

    }
}


export function isEmailAvailable(email) {
    const myreg = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,5}$/;
    if (!myreg.test(email)) {
        return false;
    }
    else {
        return true;
    }
}

export function isPhoneAvailable(phone) {
    const myreg = /^[0-9]*$/;
    if (!myreg.test(phone)) {
        return false;
    }
    else {
        return true;
    }
}



